#include "HttpServer.hpp"

using namespace LogModule;

void Login(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入登录模块" << req.Path() << ", " << req.Args();
}
void Register(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入注册模块" << req.Path() << ", " << req.Args();
}

void Search(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入搜索模块" << req.Path() << ", " << req.Args();
}

void Test(HttpRequest &req, HttpResponse &resp)
{
    // 根据req，动态构建resp
    LOG(LogLevel::DEBUG) << "进入测试模块" << req.Path() << ", " << req.Args();
}

int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    auto httpserver = std::make_unique<HttpServer>(std::stoi(argv[1]));
    // 要让服务器具有登录功能
    httpserver->Resgiter("/login", Login);
    httpserver->Resgiter("/register", Register);
    httpserver->Resgiter("/search", Search);
    httpserver->Resgiter("/test", Test);
    httpserver->Start();
    return 0;
}